package cd.safe.school.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import cd.safe.school.R;

public class GalleryAdapter extends BaseAdapter {
	private Context context;
	private List<Bitmap> lists;
	private int i = 0;

	public GalleryAdapter(Context context, List<Bitmap> lists) {
		super();
		this.context = context;
		this.lists = lists;
	}

	public int getCount() {

		// return Integer.MAX_VALUE;
		return lists.size();
	}

	public Object getItem(int position) {

		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		if (convertView == null) {
			LayoutInflater lf = LayoutInflater.from(context);
			convertView = lf.inflate(R.layout.english_gallery_item, null);
		}

		ImageView gallery_bac = (ImageView) convertView
				.findViewById(R.id.gallery_bac);
		// ImageView gallery_qac = (ImageView) convertView
		// .findViewById(R.id.gallery_qac);

		gallery_bac.setImageBitmap(lists.get(position));
		convertView.setTag(i++);

		// convertView.setOnLongClickListener(new OnLongClickListener() {
		//
		// @Override
		// public boolean onLongClick(View v) {
		// gallery_qac.setVisibility(View.VISIBLE);
		// notifyDataSetChanged();
		// return true;
		// }
		// });

		// ImageView imageView = new ImageView(context);

		// Bitmap bit = lists.get(position % lists.size());
		// Bitmap bit = lists.get(position);

		// imageView.setImageBitmap(bit);
		// 设置imageView大小 ，也就是最终显示的图片大小
		// imageView.setLayoutParams(new Gallery.LayoutParams(
		// LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
		// imageView.setScaleType(ScaleType.CENTER);

		return convertView;
	}
}
